﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FormBase
{
    public partial class FOption : Form
    {
        //CProject mProject = Program.gProject;
        public FOption()
        {
            InitializeComponent();
        }

        private void FOption_Load(object sender, EventArgs e)
        {
            Text = "Option";

            // tab 0
            //if (mProject.IsBarCode1D)
            //    rdo1D.Checked = true;
            //else
            //    rdo2D.Checked = true;
            //txtSpeed1D.Text = mProject.Speed1D.ToString();
            //txtSpeed2D.Text = mProject.Speed2D.ToString();

            // tab 1
            chkDebug.Checked = CProject.mApp.mbDebug;
            if (CProject.mEnvironment == enumEnvironment.Production)
            {
                groupBoxDebug.Enabled = false;
            }
            else
            {
                groupBoxDebug.Enabled = true;
            }

        }


        private void btnApply1_Click(object sender, EventArgs e)
        {
            CProject.mApp.mbDebug = chkDebug.Checked;
        }

        private void myApply0()
        {
            int i1;
            double d1;

            //if (rdo1D.Checked)
            //    mProject.IsBarCode1D = true;
            //else
            //    mProject.IsBarCode1D = false;

            //if (!int.TryParse(txtScene.Text.TrimEnd(), out i1))
            //    i1 = 0;
            //if (i1 > 3)
            //    i1 = 3;
            //mProject.Scene = i1;

            //if (!double.TryParse(txtSpeed1D.Text.TrimEnd(), out d1))
            //    d1 = 0.0;
            //if (d1 > 6.0)
            //    d1 = 6.0;
            //if (d1 < 1.0)
            //    d1 = 1.0;
            //mProject.Speed1D = d1;

            //if (!double.TryParse(txtSpeed2D.Text.TrimEnd(), out d1))
            //    d1 = 0.0;
            //if (d1 > 3.0)
            //    d1 = 3.0;
            //if (d1 < 1.0)
            //    d1 = 1.0;
            //mProject.Speed2D = d1;
        }
        private void btnApply0_Click(object sender, EventArgs e)
        {
            myApply0();
        }

        private void btnDefault1D_Click(object sender, EventArgs e)
        {
            rdo1D.Checked = true;
            //txtSpeed.Text = "1.0";
            //txtSpeed.Text = "5.0";
            txtSpeed1D.Text = "2.0"; // 1 to 6
            myApply0();

        }

        private void btnDefault2D_Click(object sender, EventArgs e)
        {
            rdo2D.Checked = true;
            //txtSpeed.Text = "5.0";
            txtSpeed2D.Text = "3.0"; // 1 to 3
            myApply0();

        }

        private void btnApply1_Click_1(object sender, EventArgs e)
        {
            if (chkDebug.Checked)
                CProject.mApp.mbDebug = true;
            else
                CProject.mApp.mbDebug = false;
        }
    }
}
